package com.qidian.mes.util.pojo;


import com.qidian.mes.util.Constant;

/**
 * @Author 戴着假发的程序员
 * @Company 起点编程
 * @Time 2023/10/18 10:21
 * @Description
 */
public class MESResult<T> {
    private Integer code;
    private String msg;
    private T data;
    public MESResult() {
    }
    public MESResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static MESResult ok(){
        return new MESResult(Constant.RESULT_OK,null,null);
    }
    public static MESResult ok(int code){
        return new MESResult(code,null,null);
    }
    public static MESResult ok(String msg){
        return new MESResult(Constant.RESULT_OK,msg,null);
    }
    public static MESResult ok(Object data){
        return new MESResult(Constant.RESULT_OK,"",data);
    }
    public static MESResult ok(String msg, Object data){
        return new MESResult(Constant.RESULT_OK,msg,data);
    }

    public static MESResult updateIsOk(int result){
        return result == 1?ok():fail();
    };

    public static MESResult fail(){
        return new MESResult(Constant.RESULT_OK,null,null);
    }
    public static MESResult fail(int code){
        return new MESResult(code,null,null);
    }
    public static MESResult fail(String msg){
        return new MESResult(Constant.RESULT_FAL,msg,null);
    }
    public static MESResult fail(Object data){
        return new MESResult(Constant.RESULT_FAL,"",data);
    }
    public static MESResult fail(String msg, Object data){
        return new MESResult(Constant.RESULT_FAL,msg,data);
    }
    // 还有一些其他的方法....
    public static MESResult empty(){
        return new MESResult(Constant.RESULT_EMPTY
                ,null,null);
    }
    public static MESResult empty(int code){
        return new MESResult(code,null,null);
    }
    public static MESResult empty(String msg){
        return new MESResult(Constant.RESULT_EMPTY,msg,null);
    }
    public static MESResult empty(Object data){
        return new MESResult(Constant.RESULT_EMPTY,"",data);
    }
    public static MESResult empty(String msg, Object data){
        return new MESResult(Constant.RESULT_EMPTY,msg,data);
    }


    public static MESResult duplicate(){
        return new MESResult(Constant.RESULT_DUPLICATE
                ,null,null);
    }
    public static MESResult duplicate(int code){
        return new MESResult(code,null,null);
    }
    public static MESResult duplicate(String msg){
        return new MESResult(Constant.RESULT_DUPLICATE,msg,null);
    }
    public static MESResult duplicate(Object data){
        return new MESResult(Constant.RESULT_DUPLICATE,"",data);
    }
    public static MESResult duplicate(String msg, Object data){
        return new MESResult(Constant.RESULT_DUPLICATE,msg,data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
